import {saveShipmentBox, saveShipmentBoxV2, saveShipmentGoods} from "@/api/shipment";
import {saveBoxLabelScan} from "@/api/hardware";
import {box} from "echarts/lib/util/layout";

export default {
  name: 'shipmentMixin',
  methods: {
    // 保存箱子
    saveShipmentBox(id, shipmentBox){
      const data = {
        id: id,
        shipmentBox: shipmentBox,
      }
      saveShipmentBox(data)
        .then(res=>{

        })
    },
    saveShipmentBoxV2(row,shipmentId){
      const data = {
        id: row.id,
        shipmentId: shipmentId,
        rlBoxNum: row.rlBoxNum,
      }
      saveShipmentBoxV2(data)
        .then(res=>{
          row.save = true
        })
    },
    // 保存商品数据
    saveShipmentGoods(shipmentGoods){
      const data = {
        id: shipmentGoods.id,
        rlGoodsNum: shipmentGoods.rlGoodsNum === undefined ? 0 : shipmentGoods.rlGoodsNum,
        rlGoodsBoxNum: shipmentGoods.rlGoodsBoxNum === undefined ? 0 : shipmentGoods.rlGoodsBoxNum,
        rlGoodsMixinNum: shipmentGoods.rlGoodsMixinNum === undefined ? 0 : shipmentGoods.rlGoodsMixinNum,
      }
      saveShipmentGoods(data)
        .then(res=>{
          if(res.error === 0){
            shipmentGoods.save = true
          }
        })
    },
    // 标记箱标已被扫描入库
    saveBoxLabelScan(boxId){
      if(!boxId){
        return;
      }
      saveBoxLabelScan(boxId)
        .then(res=>{

        })
    }
  }
}
